<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>提交历史表单</title>
	<meta name="decorator" content="default"/>
	<link href="${ctxStatic}/oa/css/budgetForm.css" rel="stylesheet" />

	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		$(function() {
			(function ($) {
				var Budget = function () {}
				Budget.prototype.collect = function (e) {
					var sum = 0;
					$(".fee").each(function(){
						sum = Number($(this).val())+sum;
						sum = Math.round(sum*10000)/10000;
					});
					$("#aggregate").val(sum);
				}
				$('.fee').on('change',Budget.prototype.collect);
				$('.fee').on('mouseleave',Budget.prototype.collect);
				$('.btn-primary').on('click',Budget.prototype.collect);
			})(jQuery);
		})
		var electricityPrice = ${fns:getDictValue('电费','0_df_electricity_price','1')};
		var postagePrice = ${fns:getDictValue('邮电费','	0_ydf_postage_price','1')};
		var travelExpenseStandard = ${fns:getDictValue('差旅费标准','0_clf_travel_expense_standard','1')};
		var otherTrafficFeeStandard = ${fns:getDictValue('其它交通费标准','0_qtjtf_other_traffic_fee_standard','1')};
		var blackWhitePrintStandard = ${fns:getDictValue('黑白印刷标准','0_ydf_black_white_print_standard','1')};
		var colorPrintStandard = ${fns:getDictValue('彩色印刷标准','0_ysf_color_print_standard','1')};
		var wholePrintStandard = ${fns:getDictValue('整本印刷标准','	0_ysf_whole_print_standard','1')};
		var internationalTrafficFeeStandard = ${fns:getDictValue('国际合作交流交通费标准','0_gjf_international_traffic_fee_standard','1')};
		var internationalAccommodationFeeStandard = ${fns:getDictValue('国际合作交流食宿费标准','	0_gjf_international_accommodation_fee_standard','1')};
		var internationalIncidentalsFeeStandard = ${fns:getDictValue('国际合作交流公杂费标准','0_gjf_international_incidentals_fee_standard','1')};
		var trainingFeeStandard = ${fns:getDictValue('培训费标准','0_pxf_training_fee_standard','1')};
		var specialistFeeStandardJson = '${fns:getDictListJson("0_specialist_fee")}';//专家咨询费标准
		var specialistFeeStandards = JSON.parse(specialistFeeStandardJson);
		var yesOrNoJson = '${fns:getDictListJson("yes_no")}';//yes_no
		var yesOrNo = JSON.parse(yesOrNoJson);
	</script>
	<script src="${ctxStatic}/oa/js/budgetForm.js" type="text/javascript"></script>
</head>
<body>
	<ul class="nav nav-tabs">
		<%--<li><a href="${ctx}/oa/testAudit/">审批列表</a></li>--%>
		<li class="active"><a href="${ctx}/oa/testAudit/form/?procInsId=${testAudit.procInsId}">历史记录</a></li>
	</ul>
	<form:form class="form-horizontal" modelAttribute="budget">
		<sys:message content="${message}"/>
		<fieldset>
			<legend>历史记录</legend>
			<table class="table-form">
				<tr>
					<td class="tit">项目名称</td>
					<td colspan="2">
						${budget.title}
					</td>
					<td class="tit">预算年度</td>
					<td colspan="2">
							${budget.annual}
					</td>
				</tr>
				<tr>
					<td class="tit">项目分类</td>
					<td colspan="2">
						<sys:treeselect id="classify" name="classify.id" value="${budget.classify.id}" labelName="classify.name" labelValue="${budget.classify.name}"
										title="项目分类" url="/sys/classify/treeData?type=2" cssClass="required recipient" cssStyle="width:150px"
										allowClear="true" notAllowSelectParent="true" smallBtn="false"/>
					</td>
					<td class="tit">所属项目</td>
					<td colspan="2">
						<sys:treeselect id="category" name="category.id" value="${budget.category.id}" labelName="category.name" labelValue="${budget.category.name}"
										title="所属项目" url="/sys/category/treeData?type=2" cssClass="required recipient" cssStyle="width:150px"
										allowClear="true" notAllowSelectParent="true" smallBtn="false"/>
					</td>
				</tr>
				<tr>
					<td class="tit" >科目</td>
					<td colspan="5">
					</td>
				</tr>
				<%--<c:forEach items="${budget.subjectList}"  step="1" varStatus="status">

					<c:choose>

						<c:when test="${status.index % 2 == 0}">
							<tr>
							<td class="tit">[${budget.subjectList[status.index].code}]${budget.subjectList[status.index].name}</td>
							<td colspan="2">
								${budget.subjectList[status.index].money}万元
							</td>
							<c:if test="${status.last}">
								</tr>
							</c:if>
						</c:when>
						<c:otherwise>
							<c:if test="${status.first}">
								<tr>
							</c:if>
							<td class="tit">[${budget.subjectList[status.index].code}]${budget.subjectList[status.index].name}</td>
							<td colspan="2">
									${budget.subjectList[status.index].money}万元
							</td>
							</tr>
						</c:otherwise>
					</c:choose>
				</c:forEach>--%>
				<c:forEach items="${budget.subjectList}"  step="1" varStatus="status">
					<c:choose>
						<c:when test="${status.index % 2 == 0}">
							<tr>
							<td class="tit">
								<c:choose>
									<c:when test="${budget.subjectList[status.index].createBy.id == 2}">
										<font style="color:red">
											[${budget.subjectList[status.index].code}]${budget.subjectList[status.index].name}
										</font>
									</c:when>
									<c:otherwise>
										[${budget.subjectList[status.index].code}]${budget.subjectList[status.index].name}
									</c:otherwise>
								</c:choose>
							</td>
							<td colspan="2">
								<c:choose>
									<c:when test="${budget.subjectList[status.index].createBy.id == 2}">
										<input subjectCode="${budget.subjectList[status.index].code}" subjectName="${budget.subjectList[status.index].name}"  class="fee required" readonly id="subjectList${budget.subjectList[status.index].id}money" type="positiveDecimal" name="subjectList[${budget.subjectList[status.index].id}].money" value="<c:choose><c:when test="${not empty budget.subjectList[status.index].money}">${budget.subjectList[status.index].money}</c:when><c:otherwise>0</c:otherwise></c:choose>">万元
									</c:when>
									<c:otherwise>
										<input subjectCode="${budget.subjectList[status.index].code}" subjectName="${budget.subjectList[status.index].name}"  class="fee required" readonly id="subjectList${budget.subjectList[status.index].id}money" type="positiveDecimal" name="subjectList[${budget.subjectList[status.index].id}].money" value="<c:choose><c:when test="${not empty budget.subjectList[status.index].money}">${budget.subjectList[status.index].money}</c:when><c:otherwise>0</c:otherwise></c:choose>">万元
									</c:otherwise>
								</c:choose>
								<input id="subjectList[${budget.subjectList[status.index].id}].id" name="subjectList[${budget.subjectList[status.index].id}].id" value="${budget.subjectList[status.index].id}" type="hidden">
								<input id="subjectListDetail[${budget.subjectList[status.index].id}].id" name="subjectList[${budget.subjectList[status.index].id}].details" value="${budget.subjectList[status.index].details}" type="hidden">
							</td>
							<c:if test="${status.last}">
								</tr>
							</c:if>
						</c:when>
						<c:otherwise>
							<c:if test="${status.first}">
								<tr>
							</c:if>
							<td class="tit">
								<c:choose>
									<c:when test="${budget.subjectList[status.index].createBy.id == 2}">
										<font style="color:red">
											[${budget.subjectList[status.index].code}]${budget.subjectList[status.index].name}
										</font>
									</c:when>
									<c:otherwise>
										[${budget.subjectList[status.index].code}]${budget.subjectList[status.index].name}
									</c:otherwise>
								</c:choose>
							</td>
							<td colspan="2">
								<c:choose>
									<c:when test="${budget.subjectList[status.index].createBy.id == 2}">
										<input subjectCode="${budget.subjectList[status.index].code}" subjectName="${budget.subjectList[status.index].name}"  class="fee required" readonly id="subjectList${budget.subjectList[status.index].id}money" type="positiveDecimal" name="subjectList[${budget.subjectList[status.index].id}].money" value="<c:choose><c:when test="${not empty budget.subjectList[status.index].money}">${budget.subjectList[status.index].money}</c:when><c:otherwise>0</c:otherwise></c:choose>">万元
									</c:when>
									<c:otherwise>
										<input subjectCode="${budget.subjectList[status.index].code}" subjectName="${budget.subjectList[status.index].name}"  class="fee required" readonly id="subjectList${budget.subjectList[status.index].id}money" type="positiveDecimal" name="subjectList[${budget.subjectList[status.index].id}].money" value="<c:choose><c:when test="${not empty budget.subjectList[status.index].money}">${budget.subjectList[status.index].money}</c:when><c:otherwise>0</c:otherwise></c:choose>">万元
									</c:otherwise>
								</c:choose>
								<input id="subjectList[${budget.subjectList[status.index].id}].id" name="subjectList[${budget.subjectList[status.index].id}].id" value="${budget.subjectList[status.index].id}" type="hidden">
								<input id="subjectListDetail[${budget.subjectList[status.index].id}].id" name="subjectList[${budget.subjectList[status.index].id}].details" value="${budget.subjectList[status.index].details}" type="hidden">
							</td>
							</tr>
						</c:otherwise>
					</c:choose>
				</c:forEach>
				<tr>
					<td class="tit">总计</td>
					<td colspan="5">
						<fmt:formatNumber type="number" maxFractionDigits="4" value="${budget.aggregate}"></fmt:formatNumber>
						<%--<form:input path="aggregate" disabled="true"></form:input>万元--%>
					</td>
				</tr>
			</table>
		</fieldset>
		<div class="form-actions">
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
	<div id="myModal" style="display:none" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						&times;
					</button>
					<h4 class="modal-title" id="myModalLabel">
						<b></b>  费用总计<font>0</font>万元
					</h4>
				</div>
				<div class="modal-body">
					<div class="control-group">
						<div class="controls container">
							<div class="row">
								<div class="col-md-6">
									<table id="instrumentTable" class="table table-bordered">
										<thead>
										<%--<tr>
											<th>名称</th>
											<th>费用类型</th>
											<th>费用金额</th>
											<th>备注</th>
											<th>删除</th>
										</tr>--%>
										</thead>
										<tbody id="instrumentTbody">
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>
</body>
</html>
